package com.vaadin.tutorial.crm.backend.util;/**
 * @author: fan
 * @date: 2021/1/23 20:04
 **/

import com.vaadin.flow.component.Component;
import com.vaadin.flow.component.button.Button;
import com.vaadin.flow.component.button.ButtonVariant;
import com.vaadin.flow.component.dialog.Dialog;
import com.vaadin.flow.component.html.Div;
import com.vaadin.flow.component.icon.Icon;
import com.vaadin.flow.component.icon.VaadinIcon;
import com.vaadin.flow.component.notification.Notification;
import com.vaadin.flow.component.tabs.Tab;
import com.vaadin.flow.component.tabs.TabVariant;

/**
 *
 *公共组件封装
 *@Description:
 *@Author: Fan
 *@Date: 2021/1/23 20:04
 @Version 1.0
 *
 */
public class CommonComponent {
    //消息提示框
    public static void open_notifi(String text){
        Notification.show(text);
    }

    //tab
    public static Tab createTab(Component content, TabVariant tabVariant) {
        Tab tab = new Tab();
        tab.addThemeVariants(tabVariant);
        tab.add(content);
        return tab;
    }

    //按钮
    public static Button createButton(ButtonVariant buttonVariant, String text, VaadinIcon vaadinIcon,
                                      Boolean setIconAfterText){
        Button button = new Button();
        button.addThemeVariants(buttonVariant);
        button.setText(text);
        button.setIcon(new Icon(vaadinIcon));
        button.setIconAfterText(setIconAfterText);
        return button;
    }

    //模态框
    public static Dialog createDialog(String width, String height){
        Dialog dialog = new Dialog();
        dialog = new Dialog();
        dialog.setWidth(width);
        dialog.setHeight(height);
        return dialog;
    }

    //div
    public static Div createDiv(String text, String cssName, String cssValue){
        Div div = new Div();
        div.setText(text);
        div.getStyle().set(cssName, cssValue);
        return div;
    }
}
